package Test;

public class test1 {
    public static void main(String[] args) {
        int[] arr = {1,2,3,1};


        int result = findPeakElement(arr);

        System.out.println(result);
    }

    public static int findPeakElement(int[] nums) {
        // write code here
        if(nums.length==1){
            return 0;
        }

        for (int i = 0; i < nums.length; i++) {
            if(nums[nums.length-1]>nums[nums.length-2]){
                return nums.length-1;

            }
            else if(nums[i]>nums[i+1]){
                return i;
            }
        }
        return 0;
    }
}
